import { get, post } from '../utils/http';
import {
    API_GET_VERIFY_CODE, API_UPDATE_USER, API_ZH_LOGIN_OR_REGISTER, API_POST_ENCRYPT_DATA,
    API_DECODE_BIND
} from '../common/constants';

// 获取手机号验证码
exports.getVerifyCode = (param) => {
    return get(API_GET_VERIFY_CODE, param);
};

// 登录或注册
exports.loginOrRegister = (phone, code, header) => {
    return post(API_ZH_LOGIN_OR_REGISTER, {'phone': phone, 'code': code}, header);
};

exports.updateUser = (params) => {
    return post(API_UPDATE_USER, params);
};

exports.postEncryptData = (encryptedData, iv) => {
    return get(API_POST_ENCRYPT_DATA, {'data': encryptedData, 'iv': iv});
};

exports.getDecodeAndBind = (encryptedData, iv) => {
    return get(API_DECODE_BIND, {'data': encryptedData, 'iv': iv});
};
